import java.util.Scanner;

public class Demo2 {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            Thread cur = Thread.currentThread();
           while (!cur.isInterrupted()){
               System.out.println("t1线程正在执行");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   System.out.println("t1线程被中断");
               }
           }
            System.out.println("t1线程停止");
        });
        t1.start();
        Scanner scanner = new Scanner(System.in);
        scanner.next();
        t1.interrupt();
    }
}
